{include file="common/head"/}
<style>
    .layui-checkbox-disbaled[lay-skin=primary] span {color: black;}
</style>
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>考核项</legend>
    </fieldset>
    <form class="layui-form layui-form-pane" lay-filter="form" id="form">

        <div  v-for="(item, index) in title_data">

            <div class="layui-form-item" v-if="item.type==1" >
                <div class="layui-input-4">
                    <span> {{index+1}}.</span><textarea style="padding-top: 10px;margin-top: -27px;padding-left: 10px;border: none;margin-left: 20px" readonly cols="200" rows="2">{{item.title}}</textarea>
                </div>
            </div>
            <div class="layui-form-item" v-if="item.type==1" >
                <div class="layui-input-block" style="margin-left: 60px">
                     <span v-for="(item1, index1) in item.var_content">
                         <input :name="'timu'+item.title_id+'['+index1+']'" type="hidden" value="0" disabled>
                         <span v-if="item.answer" v-for="(item2, index2) in item.answer">

                              <input v-if="index2==index1 && item2==1" type="checkbox" lay-filter="ck" :id="'checkbox'+item.title_id+'['+index1+']'" :name="'timu'+item.title_id+'['+index1+']'" value="1" lay-skin="primary" :title="item1" checked disabled>
                              <input v-if="index2==index1 && item2!=1" type="checkbox" lay-filter="ck" :id="'checkbox'+item.title_id+'['+index1+']'" :name="'timu'+item.title_id+'['+index1+']'" value="1" lay-skin="primary" :title="item1" disabled>
                         </span>
                          <span v-if="item.answer==''">
                            <input  type="checkbox" lay-filter="ck" :id="'checkbox'+item.title_id+'['+index1+']'" :name="'timu'+item.title_id+'['+index1+']'" value="1" lay-skin="primary" :title="item1" disabled>
                        </span>
                     </span>
                </div>
            </div>


            <div class="layui-form-item"  v-if="item.type==2">

                <div class="layui-input-4">
                    <span> {{index+1}}.</span><textarea style="padding-top: 10px;margin-top: -27px;padding-left: 10px;border: none;margin-left: 20px" readonly cols="200" rows="2" >{{item.title}}</textarea>
                </div>
            </div>
            <div class="layui-form-item"  v-if="item.type==2">
                <div class="layui-input-block" style="margin-left: 60px">
                    <span v-for="(item4, key4,index4) in item.var_content">
                         <span v-if="item.answer" v-for="(item3, key3,index3) in item.answer">
                             <span v-if="key3==index4">
                                 {{item4}}:
                             </span>
                             <input v-if="key3==index4" type="text" :name="'timu'+item.title_id+'['+']'"  lay-skin="primary"  style="width: 30px;height: 20px;" :value="item3" readonly>
                             <span  style="margin-left: 30px;"></span>
                        </span>
                        <span v-if="item.answer==''">
                              {{item4}}:
                             <input type="text" :name="'timu'+item.title_id+'['+']'"  lay-skin="primary"  style="width: 30px;height: 20px;" readonly>
                            <span  style="margin-left: 30px;"></span>
                        </span>

                    </span>
                </div>
            </div>

        </div>

    </form>
    <div class="layui-form-item">
        <div class="layui-input-block">
            {if $status==0}
            <button class="layui-btn" onclick="save(1)">通过</button>
            <button class="layui-btn layui-btn-danger" onclick="save(2)">驳回</button>
            {else /}
            <button class="layui-btn layui-btn-warm">已审核</button>
            {/if}
            <a href="{:url('index')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
        </div>
    </div>
</div>
{include file="common/foot"/}
<script type="text/javascript" src="/static/common/js/vue.js"></script>
<script>

    //数据初始化
    var app = new Vue({
        el: '#form',
        data: {
            //分类
            title_data: [],
            cate_id:'',
        },

    });
    layui.use(['form', 'layer'], function () {
        var form = layui.form, layer = layui.layer, $ = layui.jquery;
        form.render();

        $.ajax({
            type: 'POST',
            dataType: 'json',
            url: "{:url('check_teacher_show')}?teacher_id="+{$teacher_id}+"&cate_id="+{$cate_id},
            success : function(res) {
                app.title_data = res.list;
                setTimeout(function () {
                    form.render();
                },500);
            },
        });


    });

    //通过
    function save(flag) {

        var  reject_reason = '';

        if (flag==2){
            //例子2
            layer.prompt({
                formType: 2,
                title: '驳回理由',
                area: ['500px', '350px'] //自定义文本域宽高
            }, function(value, index, elem){

                reject_reason  = value;
                layer.close(index);
                $.ajax({
                    type: 'POST',
                    url: "{:url('save')}?teacher_id="+{$teacher_id}+"&cate_id="+{$cate_id}+"&flag="+flag,
                    data:{reject_reason:reject_reason},
                    success: function(res){
                        if(res.code){
                            layer.msg(res.msg,{icon:1});
                            location.href = res.url+"&teacher_id="+res.data;
                        }else{
                            layer.msg(res.msg,{icon:2});
                        }

                    },
                    dataType: 'json'
                });

            });

        }else{
            $.ajax({
                type: 'POST',
                url: "{:url('save')}?teacher_id="+{$teacher_id}+"&cate_id="+{$cate_id}+"&flag="+flag,
                data:{reject_reason:reject_reason},
                success: function(res){
                    if(res.code){
                        layer.msg(res.msg,{icon:1});
                        location.href = res.url+"&teacher_id="+res.data;
                    }else{
                        layer.msg(res.msg,{icon:2});
                    }

                },
                dataType: 'json'
            });
        }


    }

</script>